<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>宏任务和微任务</title>
</head>
<body>
<script>
    //同：2 8
    //微：3 4 9 5 7 6
    //宏：1

    setTimeout(() => { // 宏
        console.log(1)
    }, 0)
    new Promise((resolve, reject) => {
        console.log(2) // 同
        resolve()
    }).then(value => {
        console.log(3) // 微
        new Promise((resolve, reject) => {
            console.log(4) // 微 中的 同，也称为 微
            resolve()
        }).then(value => {
            console.log(5) // 微
        }).then(value => {
            console.log(6) // 微
        })
    }).then(value => {
        console.log(7) // 微
    })
    new Promise((resolve, reject) => {
        console.log(8) // 同
        resolve()
    }).then(value => {
        console.log(9) // 微
    })

</script>
</body>
</html>